package com.zjitc;

import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Test;

/**
 * Create by IntelliJ IDEA
 *
 * @author: lhl
 * @date-Time: 2018/5/6 0006
 * @description:
 */
public class T {

    @Test
    public void test2() {
        String[] arr1 = new String[]{"顺丰速运", "百世快递", "中通快递", "申通快递", "圆通速递",
                "韵达速递", "邮政快递包裹", "EMS", "京东物流", "快捷快递"};
        String s = "韵达速递";
        String[] arr2 = new String[]{"SF", "HTKY", "ZTO", "STO", "YTO",
                "YD", "YZPY", "EMS", "JD", "FAST"};
        String s1 = null;
        for (int i = 0; i < arr1.length; i++) {
            if (s.equals(arr1[i])) {
                s1 = arr2[i];
                System.out.println(s1);
            }
        }
    }

    public String af(String s) {
        String[] arr1 = new String[]{"顺丰速运", "百世快递", "中通快递", "申通快递", "圆通速递",
                "韵达速递", "邮政快递包裹", "EMS", "京东物流", "快捷快递"};
        String[] arr2 = new String[]{"SF", "HTKY", "ZTO", "STO", "YTO",
                "YD", "YZPY", "EMS", "JD", "FAST"};
        String s1 = null;
        for (int i = 0; i < arr1.length; i++) {
            if (s.equals(arr1[i])) {
                s1 = arr2[i];
            }
        }
        return s1;
    }

    @Test
    public void test23() {
        String s = af("圆通速递");
        System.out.println(s);
    }

    @Test
    public void sortArrary1() {
        int arr[] = new int[]{1, 324, 12, 352, 52};
        int arr2[] = new int[]{1, 2, 3, 4, 5};
        sortArrary(arr, arr2);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i] + ":" + arr2[i]);
        }

    }

    public static void sortArrary(int[] a, int[] b) {
        int j, k = a.length;
        boolean flag = true;//发生了交换就为true, 没发生就为false，第一次判断时必须标志位true。
        while (flag) {
            flag = false;//每次开始排序前，都设置flag为未排序过
            for (j = 1; j < k; j++) {
                if (a[j - 1] > a[j]) {//前面的数字大于后面的数字就交换
                    //交换a[j-1]和a[j]
                    int temp1, temp2;
                    temp1 = a[j - 1];
                    a[j - 1] = a[j];
                    a[j] = temp1;


                    temp2 = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = temp2;

                    //表示交换过数据;
                    flag = true;
                }
            }
            k--;//减小一次排序的尾边界
        }//end while
    }//end
}
